<?php
use App\UserContract;
return [
    'title' =>  '用户合约',
    'heading' =>  '用户合约管理',
    'single' => '用户合约',
    'model' => UserContract::class,
    'columns' => [
        'id' => [
            'title' => 'ID'
        ],
        'user_name' => [
            'title' => '用户名',
            'output' => function ($value, $model) {
                $name = $model->user->name;
                return isset($name) ? $name : 'N/A';
            },
            
        ],
        'contract_name' => [
            'title' => '合约名',
            'output' => function ($value, $model) {
                $name = $model->contract->name;
                return isset($name) ? $name : 'N/A';
            },
        ],
        'created_at',
        'operation' => [
            'title'  => '管理',
            'output' => function ($value, $model) {
                return $value;
            },
            'sortable' => false,
        ],
    ],
    'edit_fields' => [
        'user' => [
            'title' => '用户名',
            'type' => 'relationship',
            'name_field' => 'name',
        ],
        'contract' => [
            'title' => '合约名',
            'type' => 'relationship',
            'name_field' => 'name',
            'constraints' => array('user' => 'contract'),
        ],
    ],
    'filters' => [
        'id' => [
            'title' => 'ID',
        ],
        'name' => [
            'title' => '用户名',
        ],
    ],
];
